var orderId;
window.onload = function () {
  orderId = getQuery("id");
  init()
};

async function init() {
    var order = await ajaxGet("/order/findById",{
        orderId:orderId
    });

    $("idDIv").innerHTML = order.orderId;
    $("personDIv").innerHTML = order.person;
    $("addressDIv").innerHTML = order.address;
    $("phoneDIv").innerHTML = order.phone;
    $("timeDIv").innerHTML = order.time;
    $("totalDIv").innerHTML = order.total;
    $("statusDIv").innerHTML = order.status;

    let str = "";
    for (let i = 0; i < order.orderInfoBeans.length; i++) {
        let orderInfo = order.orderInfoBeans[i];
        str += `<tr>
                    <td>${orderInfo.infoId}</td>
                    <td>${orderInfo.productBean.productName}</td>
                    <td>${orderInfo.price}</td>
                    <td>${orderInfo.num}</td>
                </tr>`;
    }
    $("orderInfo").innerHTML = str;
}

function back() {
    location.href = "/html/custom/showOrder.html"
}

function back1(){
    location.href = "/html/manager/pressOrder.html"
}

async function send() {
    var info = await ajaxGet("/order/send",{
        id:orderId
    });
    if (info == "ok"){
        location.href = "/html/manager/pressOrder.html";
    }else {
        alert("发货失败，请重新发货")
    }
}